package string;

public class 替换隐藏数字得到的最晚时间_1736 {
    public static String maximumTime(String time) {
        String[] split = time.split(":");
        char[] hours = split[0].toCharArray();
        char[] min = split[1].toCharArray();
        if (hours[0] == '?' && hours[1] == '?') {
            hours[0] =  '2' ;
            hours[1] =  '3';
        }else if (hours[1] == '?') {
            hours[1] = hours[0] == '2' ? '3' : '9';
        }
        if (hours[0] == '?') {
            hours[0] = hours[1] <= '3'   ? '2' : '1';
        }

        if (min[0] == '?') {
            min[0] = '5';
        }

        if (min[1] == '?') {
            min[1] = '9';
        }
        StringBuffer sb = new StringBuffer();
        sb.append(hours[0]).append(hours[1]).append(":").append(min[0]).append(min[1]);
        return sb.toString();
    }

    public static void main(String[] args) {
        maximumTime("2?:?0");
    }
}
